/*
 * Copyright (c) $today.year-Now http://www.zxpnet.com All rights reserved.
 */

package com.zxp.springboot.pojo;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;

/**
 * @desc:
 * @author: shollin
 * @date: 2021/6/16/016 6:28
 */
@Data
@ApiModel
public class HelloUser implements Serializable {

    private Long id;

    @ApiModelProperty("用户名")
    @NotBlank(message="用户名不能为空")
    private String username;

    private String name;
    private Integer age;

    private BigDecimal salary;
    private LocalDate birthday;
    private Date createTime;
    private LocalTime subtime;
    private LocalDateTime updateTime;

    private HelloUser parent;

    public static HelloUser randomUser(){
        HelloUser helloUser = new HelloUser();
        helloUser.setId(IdUtil.createSnowflake(0,1).nextId());
        helloUser.setUsername(RandomUtil.randomString(8));
        helloUser.setName(RandomUtil.randomString(6));
        helloUser.setAge(RandomUtil.randomInt(20,50));
        helloUser.setSalary(RandomUtil.randomBigDecimal(new BigDecimal("2000"),new BigDecimal("50000")) );
        helloUser.setCreateTime(RandomUtil.randomDay(-365*5,365*5));
        helloUser.setBirthday( LocalDate.now().minusDays(RandomUtil.randomLong(20*365,60*365)));
        helloUser.setSubtime(LocalTime.now());
        helloUser.setUpdateTime(LocalDateTime.now());
        return helloUser;
    }

}
